﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Input;
using DC2010;
using DC2010.Objects.Base;
using DC2010.Objects;

namespace RolePlaying.Events
{
    public class EventsInventory
    {
        public EventsInventory()
        {

            RM.Get("Inventory_0").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_1").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_2").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_3").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_4").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_5").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_6").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_7").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_8").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_9").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_10").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_11").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_12").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_13").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_14").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_15").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);

            RM.QuiverA.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.QuiverB.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.QuiverC.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.QuiverD.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.QuiverE.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.QuiverF.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);

            RM.BeltUp.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.BeltDown.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);

            RM.Neck.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.RightHand.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.LeftHand.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Head.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Body.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Legs.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Feet.OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);

            RM.Get("Inventory_Container_0").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_1").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_2").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_3").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_4").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_5").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_6").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_7").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_8").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_9").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_10").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);
            RM.Get("Inventory_Container_11").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseLeft);

            RM.Get("Inventory_Eye").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnEyeMouseLeft);
            RM.Get("Inventory_Mouth").OnMouseLeft += new ActiveRectangle.mouseStateDelegate(RM_OnMouthMouseLeft);
            RM.Get("Inventory").OnMouseRight += new ActiveRectangle.mouseStateDelegate(RM_OnInventoryMouseRight);

        }

        void RM_OnInventoryMouseLeft(MouseState state, ActiveRectangle ar)
        {
            //if (Root.I.GameSystem.SelectedMember != null)
            //{
            //    if (ar.Name.Contains("Quiver"))
            //    {
            //        Root.I.GameSystem.SwitchItem(ar.Name, Root.I.GameSystem.Party.Info.MembersBrowsable[Root.I.GameSystem.SelectedMember].Info.Equip.Quiver);
            //        return;
            //    }

            //    if (ar.Name.Contains("Body"))
            //    {
            //        Creature c = Root.I.GameSystem.Party.Info.MembersBrowsable[Root.I.GameSystem.SelectedMember];
            //        if (ar.Name.Contains("_1")) c.Info.ActionOptionsAreDisplayed_Right = false;
            //        if (ar.Name.Contains("_2")) c.Info.ActionOptionsAreDisplayed_Left = false;

            //        Root.I.GameSystem.SwitchItem(ar.Name, c.Info.Equip.Items);
            //        return;
            //    }

            //    if (ar.Name.Contains("Belt"))
            //    {
            //        Root.I.GameSystem.SwitchItem(ar.Name, Root.I.GameSystem.Party.Info.MembersBrowsable[Root.I.GameSystem.SelectedMember].Info.Equip.Belt);
            //        return;
            //    }

            //    if (ar.Name.Contains("Container"))
            //    {
            //        //string itemId = Root.I.GameSystem.Party.Members[Root.I.GameSystem.SelectedMember].Info.Equip.Items.ItemsArray[(int)EquipSlots.LeftHand];
            //        //if (itemId!=null)
            //        {
            //            string s = Root.I.GameSystem.Party.Info.MembersBrowsable[Root.I.GameSystem.SelectedMember].Info.Equip.Items.TakeItemFromPosition(EquipSlots.LeftHand);
            //            Item i = Root.I.IS.GetItem(s);

            //            Root.I.GameSystem.Party.Info.MembersBrowsable[Root.I.GameSystem.SelectedMember].Info.Equip.Items.PutItemToPosition((int)EquipSlots.LeftHand, s);

            //            Root.I.GameSystem.SwitchItem(ar.Name, i.Info.ContainerItems);
            //        }
            //        return;
            //    }

            //    if (ar.Name.Contains("Inventory_"))
            //    {
            //        Root.I.GameSystem.SwitchItem(ar.Name, Root.I.GameSystem.Party.Info.MembersBrowsable[Root.I.GameSystem.SelectedMember].Info.Inventory);
            //        return;
            //    }
            //}


        }

        void RM_OnInventoryMouseRight(MouseState state, ActiveRectangle ar)
        {
            if ((Root.I.GameSystem.CurrentScreen == "Inventory") || (Root.I.GameSystem.CurrentScreen == "Statistics"))
            {
                Root.I.GameSystem.SelectedMember = null;
                Root.I.GameSystem.CurrentScreen = "Dungeon";
            }
        }



        void RM_OnEyeMouseLeft(MouseState state, ActiveRectangle ar)
        {
            if (Root.I.GameSystem.CurrentSubScreen == "Statistics") Root.I.GameSystem.CurrentSubScreen = "";
            else
                Root.I.GameSystem.CurrentSubScreen = "Statistics";
            //else
            //{
            //    Root.I.GameSystem.CurrentScreen = "Inventory";
            //}
        }



        void RM_OnMouthMouseLeft(MouseState state, ActiveRectangle ar)
        {
            if (Root.I.GameSystem.SelectedMember != null)
            {
                Root.I.GameSystem.SelectedMember = null;
            }

        }





    }
}
